package com.cloud.screen.interfaces;

import com.cloud.screen.common.config.FeignConfiguration;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Map;

@FeignClient(value = "LAWCASE", configuration = FeignConfiguration.class, fallbackFactory = FeignClientLawCaseFallbackFactory.class)
public interface FeignClientLawCase {
    /**
     * 法律概况
     *
     * @return
     */
    @RequestMapping(value = "lawcase/interface/infogeneral", method = RequestMethod.GET)
    Map<String, Object> getInfoGeneral();

    /**
     * 执法依据
     *
     * @return
     */
    @RequestMapping(value = "lawcase/interface/statcauseexcutetype", method = RequestMethod.GET)
    List<Map<String, Object>> statCauseExcuteType();

    /**
     * 执法领域
     *
     * @return
     */
    @RequestMapping(value = "lawcase/interface/lawdomain", method = RequestMethod.GET)
    List<Map<String, Object>> getLawDomain();

    /**
     * 法律法规分组
     *
     * @return
     */
    @RequestMapping(value = "lawcase/interface/lawcodegroup", method = RequestMethod.GET)
    List<Map<String, Object>> getLawCodeGroup();
}

@Component
class FeignClientLawCaseFallbackFactory implements FallbackFactory<FeignClientLawCase> {
    private static final Logger LOGGER = LoggerFactory.getLogger(FeignClientLawCaseFallbackFactory.class);

    @Override
    public FeignClientLawCase create(final Throwable cause) {
        return new FeignClientLawCase() {

            @Override
            public Map<String, Object> getInfoGeneral() {
                return null;
            }

            @Override
            public List<Map<String, Object>> statCauseExcuteType() {
                return null;
            }

            @Override
            public List<Map<String, Object>> getLawDomain() {
                return null;
            }

            @Override
            public List<Map<String, Object>> getLawCodeGroup() {
                return null;
            }
        };
    }

}
